<template>
	<view>
		<view class="notice">
			<view class="not_Title">
				您好，请登录~
			</view>
		</view>
		<view class="input">
			<view class="input_area">
				<view class="input_tit">账号</view>
				<view class="input_not">
					<input v-model="account" border="none" clearable placeholder="请输入登录账号"></input>
				</view>
			</view>
			<view class="input_area">
				<view class="input_tit">密码</view>
				<view class="input_not">
					<input v-model="password" border="none" clearable placeholder="请输入您的密码" type="password"></input>
				</view>
				<view class="input_fpwd">忘记密码</view>
			</view>
		</view>
		<view class="deal">
			<view class="agree">
				<view>
					<label class="radio" @click="changeAgree">
						<radio value="r1" :checked="isAgree" style="transform:scale(0.7)" />
					</label>
				</view>
				<view class="deal_sup">
					同意
					<view class="">《淘物熊服务协议》</view>
					和
					<view class="">《隐私协议》</view>
				</view>
			</view>
		</view>
		<view class="loginBtn" @click="login">登录</view>
	</view>
</template>

<script>
	import {
		getLogin
	}
	from '../../api/login/login.js'
	export default {
		data() {
			return {
				isAgree: false, // 是否同意
				account: '', // 账号
				password: '' // 密码
			}
		},
		onLoad() {

		},
		methods: {
			changeAgree() {
				this.isAgree = !this.isAgree
			},
			// 登录
			login() {
				if (this.isAgree == false) {
					uni.showToast({
						icon: 'none',
						duration: 1000,
						title: `未同意协议`
					});
					return;
				}
				const data = {
					account: this.account,
					password: this.password,
					client_type: "商家",
				}
				getLogin(data).then(res => {
					uni.setStorageSync("token", res.data.userinfo.token);
					uni.showToast({
						icon: 'none',
						duration: 1000,
						title: `${res.msg}`
					});
					setTimeout(function() {
						uni.switchTab({
							url: '/pages/index/index'
						})
					}, 1000);
				}).catch(error => {
					console.log(error);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	//提示
	.notice {
		color: #4D4D4D;
		height: 25vh;
		padding: 0 80rpx;
		background: linear-gradient(#FD7F32, #FFFFFF);
		position: relative;

		//标题
		.not_Title {
			position: absolute;
			bottom: 120rpx;
			font-size: 40rpx;
		}
	}

	//输入区
	.input {
		padding: 40rpx 80rpx;
		display: flex;
		flex-direction: column;

		//账号 密码
		.input_area {
			display: flex;
			flex-direction: row;
			align-items: center;
			height: 80rpx;
			margin: 20rpx 0;
			border-bottom: 1px solid #EDEDED;

			//标题
			.input_tit {
				font-size: 34rpx;
				color: #4D4D4D;
				font-weight: bold;
				width: 20%;
			}

			//忘记密码
			.input_fpwd {
				color: #656565;
				font-size: 24rpx;
				position: fixed;
				right: 100rpx;
			}
		}
	}

	//同意协议
	.deal {
		padding: 0 80rpx;
		display: flex;
		flex-direction: column;

		//同意
		.agree {
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		//协议补充
		.deal_sup {
			display: flex;
			flex-direction: row;
			color: #838383;
			font-size: 22rpx;
		}
	}

	//登录按钮
	.loginBtn {
		color: white;
		background-color: #ff9439;
		margin: 80rpx;
		height: 100rpx;
		font-size: 35rpx;
		border-radius: 15rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}
</style>